package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.query.QuestionPageQuery;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author Aimer
 * @since 2025-11-10
 */
@RestController
@RequestMapping("/questions")
@Api(tags = "问题模块")
@RequiredArgsConstructor
public class InteractionQuestionController {
    private final IInteractionQuestionService iInteractionQuestionService;

    @ApiOperation("添加用户提问信息接口")
    @PostMapping
    public void addQuestion(@Valid @RequestBody QuestionFormDTO questionDTO){
        iInteractionQuestionService.addQuestion(questionDTO);
    }

    @ApiOperation(("分页查询提问信息"))
    @GetMapping("page")
    public PageDTO<QuestionVO> pageQuestions(QuestionPageQuery questionPageQuery){
        return iInteractionQuestionService.pageQuestions(questionPageQuery);
    }

    @ApiOperation("查询问题信息详情")
    @GetMapping("/{id}")
    public QuestionVO getByQuestion(@PathVariable Long id){
       return iInteractionQuestionService.getByQuestion(id);
    }

    @ApiOperation("删除我的问题")
    @DeleteMapping("/{id}")
    public void removeQuestion(@PathVariable Long id){
        iInteractionQuestionService.removeQuestion(id);
    }

    @ApiOperation("修改问题")
    @PutMapping("/{id}")
    public void updateQuestion(@PathVariable Long id,@RequestBody QuestionFormDTO questionDTO){
        iInteractionQuestionService.updateQuestion(id,questionDTO);
    }
}
